#include <stdio.h>
#include <ctype.h>
float compute_GPA(char grades[], int n) {
    int sum = 0;
    for (int i = 0; i < n; i++) {
        switch (tolower(grades[i]))
        {
        case 'a':
            sum += 4;
            break;
        case 'b':
            sum += 3;
            break;
        case 'c':
            sum += 2;
            break;
        case 'd':
            sum += 1;
            break;
        case 'f':
            break;
        }
    }
    return (float) sum / n;
}
int main(void)
{
    int n;
    printf("一共几门课: ");
    scanf("%d", &n);
    printf("依次输入字母等级: ");
    char grades[n];
    for (int i = 0; i < n; i++)
        scanf(" %c", &grades[i]);
    printf("平均值: %.2f\n", compute_GPA(grades, n));
    return 0;
}